$(function(){
    var now = new Date();
   
    var year = now.getFullYear();       //年
    var month = now.getMonth() + 1;     //月
    var day = now.getDate();            //日
    var hh = now.getHours();            //时
    var mm = now.getMinutes();          //分
    var clock = year + "-";
    if(month < 10){
        clock += "0";
    }else{
        clock += month + "-";
    }

    if(day < 10){
        clock += "0";
    }else{
        clock += day + " ";	
    }

    if(hh < 10){
        clock += "0";
    }else{
        clock += hh + ":";
    }

    if (mm < 10){
    	clock += '0'; 
    }else{
        clock += mm; 
    }
	
	var levelName = 'Error';
	var begindate = clock;
	var enddate = clock;
	
	
	$('#begindate').datetimebox({    
	    value: begindate,    
	    required: true,    
	    showSeconds: false,
	    onSelect: function(date){
	    	var year = date.getFullYear();  
	        var month = date.getMonth() + 1;  
	        var day = date.getDate();  
	        var time=$('#begindate').datetimebox('spinner').spinner('getValue');  
	        begindate = year + "-" + (month < 10 ? ("0" + month) : month) + "-" + (day < 10 ? ("0" + day) : day) +' '+time;  
	        $('#begindate').datetimebox('setText', begindate);  
	        $('#begindate').datetimebox('hidePanel');
	        showCheck();
	    }
	});
	
	$('#enddate').datetimebox({    
	    value: enddate,    
	    required: true,    
	    showSeconds: false,
	    onSelect: function(date){
	    	var year = date.getFullYear();  
	        var month = date.getMonth() + 1;  
	        var day = date.getDate();  
	        var time=$('#enddate').datetimebox('spinner').spinner('getValue');  
	        enddate = year + "-" + (month < 10 ? ("0" + month) : month) + "-" + (day < 10 ? ("0" + day) : day) +' '+time;  
	        $('#enddate').datetimebox('setText', enddate);  
	        $('#enddate').datetimebox('hidePanel');
	        showCheck();
	    }
	});
	
	$('#levelName').combobox({
		onSelect: function(date){
			levelName = date.value;
			showCheck();
		}
	});
	begindate=$("#begindate").datetimebox('getValue');
	enddate=$('#enddate').datetimebox('getValue');
	var showCheck = function(){
		var params={
				levelName:levelName,
				begindate: begindate,
				enddate: enddate
		};
		console.log(params);
		
		$.postJson(contextpath+'/system/journal/check',params,function(result) {
			console.log(result);
			if(result.code==200) {
				$('#checks').html(result.data);
			} else {
				top.showInfo('加载失败!');
			}
		});
	}
	showCheck();
});